export default {
  data() {
    const validatePass = (rule, value, callback) => {
      if (!value) {
        callback(new Error('请勾选注册协议'));
      } else {
        callback();
      }
    };
    return {
      formData: {
        servceType: [],
        itemType: '',
        servceDes: "",
        startTime: "",
        endTime: "",
        servceStatus: "",
        servceAddress: [],
        address: "", // 详情地址
        preAddr:"", // 服务地址
        mobeil: "",
        picture: [],
        fileUrl: [],
        readChecked: false,
        longitude:"",
        latitude:"",
        provinceCode:"",
        cityCode:"",
        areaCode:"",
        areaName:"",
        cityName:"",
        provinceName:"",
      },
      rules: {
        servceType: [{type: 'array',required: true, message: '请选择服务类型', trigger: 'change'}],
        servceDes: [{required: true, message: '请输入服务描述', trigger: 'blur'}],
        startTime: [{required: true, message: '请选择开始时间', trigger: 'blur'}],
        endTime: [{required: true, message: '请选择结束时间', trigger: 'blur'}],
        servceStatus: [{required: true, message: '请选择服务状态', trigger: 'change'}],
        servceAddress: [{type: 'array', required: true, message: '请选择服务地址', trigger: 'change'}],
        preAddr: [
          {required: true, message: '请选择地址', trigger: ['blur', 'change']}
        ],
        mobeil: [{
          required: true, 
          trigger: 'blur',
          validator: (rule, value, callback) => {
            if (!this.regCheck('empty', value)) {
              callback(new Error('请输入对外服务电话'));
            } else if (this.regCheck('fmPhone', value)) {
              callback(new Error('请输入正确的手机号或者座机号'));
            } else {
              callback()
            }
          }
        }],
        picture: [{type: 'array',required: true, message: '请上传相关图片', trigger: 'change'}],
        fileUrl: [{type: 'array',required: true, message: '请上传入驻材料', trigger: 'change'}],
        readChecked: [{validator: validatePass, trigger: 'change'}]
      }
    }
  }
}
